package org.jsola.hr.web;

import org.jsola.core.Result;
import org.jsola.hr.constant.HrConstants;
import org.jsola.hr.query.PunchRecordQuery;
import org.jsola.hr.service.IAttendPunchAppStatService;
import org.jsola.hr.vo.PunchRecordVO;
import org.jsola.user.core.TokenUser;
import org.jsola.user.core.UserContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author wxz
 */
@RestController("hrAttendPunchAppStatController")
@RequestMapping(HrConstants.API_PATH + "/v1/attendPunchAppStat")
public class AttendPunchAppStatController implements  IAttendPunchAppStatControllerAPI {

    @Autowired
    private IAttendPunchAppStatService attendPunchAppStatService;

    /**
     * 查询考勤打卡记录
     *
     * @param punchRecordQuery 考勤打卡记录查询参数
     * @return
     */
    @Override
    @GetMapping(value = "findPunchRecord")
    public Result<List<PunchRecordVO>> findPunchRecord(PunchRecordQuery punchRecordQuery) {

        TokenUser tokenUser = UserContext.getUser();
        // todo 新增考勤方案权限校验

        return Result.success(
                attendPunchAppStatService.selectPunchRecord(punchRecordQuery, tokenUser)
        );
    }
}
